import React, { useState } from 'react';
import './index.css'; // 导入样式文件

// 用户列表组件
const UserList = ({ users, deleteUser }) => {
    return (
        <table>
            <thead>
                <tr>
                    <th>用户名</th>
                    <th>性别</th>
                    <th>年龄</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {users.map((user) => (
                    <tr key={user.id}>
                        <td>{user.userName}</td>
                        <td>{user.sex}</td>
                        <td>{user.age}</td>
                        <td><button onClick={() => deleteUser(user.id)}>删除</button></td>
                    </tr>
                ))}
            </tbody>
        </table>
    );
};

export default UserList;